package com.jh.microservice.base;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;

/**
 * @author Administrator
 * @projectName newforward
 * @title
 * @package com.jh.microservice.base
 * @description
 * @date 2019/7/21 23:53
 */
@Configuration
public class SpringAnnotationDemo {

    public static void main(String[] args) {
        // Annotation注解驱动上下文，类似ClassPathXMLApplicationContext，主要作用就是找@Configration和@Component
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        // 注册一个Configuration class 到SpringAnnotationDemo
        context.register(SpringAnnotationDemo.class);
        // 上下文启动
        context.refresh();

        System.out.println(context.getBean(SpringAnnotationDemo.class));
    }

}
